package com.liu.fresh.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.liu.fresh.biz.IAdminInfoBiz;
import com.liu.fresh.biz.IMenberInfoBiz;
import com.liu.fresh.entity.AdminInfo;
import com.liu.fresh.entity.MenberInfo;
import com.liu.fresh.mapper.IAdminInfoMapper;
import com.liu.fresh.mapper.IMenberInfoMapper;
import com.liu.fresh.util.StringUtil;




@Service
public class MenberInfoBizImpl implements IMenberInfoBiz {
	@Autowired
	private IMenberInfoMapper mapper;

	@Override
	public int checkInfo(Map<String, String> map) {
		if(StringUtil.checkNull(map.get("email"), map.get("aname"))){
			return -1;
		}
		return mapper.checkInfo(map);
	}

	@Override
	public MenberInfo login(String nickName, String pwd) {
		if(StringUtil.checkNull(nickName ,pwd)){
			return null;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("nickname", nickName);
		map.put("pwd", pwd);
		return mapper.login(map);
	}

	@Override
	public int reg(Map<String, Object> map) {
		if(StringUtil.checkNull(map.get("nickname"), map.get("pwd"), map.get("tel"), map.get("email"), map.get("regDate"))){			
			System.out.println("有空值");
			return -1;
		}
		System.out.println("无空值");
		return mapper.reg(map);
	}

	@Override
	public int checkName(String nickname) {
		if(StringUtil.checkNull(nickname)){
			return 0;
		}
		Map<String, String> map = new HashMap<String, String>();
		map.put("nickname", nickname);
		return mapper.checkName(map);
	}

	@Override
	public int checkTel(String tel) {
		if(StringUtil.checkNull(tel)){
			return 0;
		}
		Map<String, String> map = new HashMap<String, String>();
		map.put("tel", tel);
		return mapper.checkTel(map);
	}

	@Override
	public int checkEmail(String email) {
		if(StringUtil.checkNull(email)){
			return 0;
		}
		Map<String, String> map = new HashMap<String, String>();
		map.put("email", email);
		return mapper.checkEmail(map);
	}

	@Override
	public Integer getTotal(String no) {
		if(StringUtil.checkNull(no)){
			return (Integer) null;
		}
		System.out.println(no);
		Map<String, String> map = new HashMap<String, String>();
		map.put("no", no);
		return mapper.getTotal(map);
	}

	@Override
	public List<MenberInfo> findAll() {
		return mapper.findAll();
	}

	@Override
	public int del(String mno) {
		if(StringUtil.checkNull(mno)){
			return 0;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("mno", mno);
		return mapper.del(map);
	}

}
